<template>
  <div v-show="isShow" class="toast">
    <div> {{message}} </div>
  </div>
</template>

<script>
export default {
  name: "Toast",
  data() {
    return {
      message: '',
      isShow: false
    }
  },
  methods:{
    show(message='默认信息', time=1500){
      this.message = message;
      this.isShow = true;

      setTimeout(() => {
        this.message = '';
        this.isShow = false
      },time)
    }
  }
}
</script>

<style scoped>
  .toast{
    top: 50%;
    left: 50%;
    padding: 8px 10px;
    transform: translate(-50% , -50%);

    background-color: rgba(0,0,0,.5);
    color: #f2f2f2;

    position: fixed;

    z-index: 99;


  }
</style>
